import upyun
import requests
import os
from upyun import BaseReporter

overSize = 0
class rep(BaseReporter):
    def __init__(a,doneSize,fileSize,over):
        os.system('cls')
        print('传输进度：' + str(((doneSize / fileSize) * 100)) +'%')
        if over:
                print('传输已完成。')
                overSize = 0

#常量信息
host = 'dreamelf-blog'
usn = 'publicuser'
pwd = 'v0uJv4AGmbdbElOxix8bCmAax3xrJFyQ'

#初始化
up = upyun.UpYun(host,usn,pwd,endpoint=upyun.ED_AUTO)

#选择文件路径
filename = input('选择路径（或拖入文件）：')
file = os.path.split(filename)[1]
print('准备上传' + file+'到云空间')
#正式上传
print('传输开始...')
with open(filename,'rb') as f:
    res = up.put('/video/SQLstu/' + file,f,need_resume=True,reporter=rep)
print('预计云路径：https://video.dreamelf.cn/video/SQLstu/' + file)
